package com.senven.branch.controller;

import com.senven.branch.service.BranchService;
import com.senven.common.entity.Branch;
import com.senven.common.vo.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author wt
 * @Date 2022/8/29 17:56
 * @PackageName:com.senven.branch
 * @ClassName: controller
 * @Description: TODO
 * @Version 1.0
 */
@RestController
@RequestMapping("/branch")
public class BranchController {
    @Autowired
    private BranchService branchService;

    //响应式---查询所有店铺
    @PostMapping("/findAll")
    public CommonResult findAll(){
        CommonResult result = branchService.findAll();
        return result;
    }
    //响应式----通过店铺id查询店铺信息
    @PostMapping("/findById")
    public CommonResult findById(Integer id){
        CommonResult result = branchService.findById(id);
        return result;
    }

    //后台---查询所有店铺
    @PostMapping("/backFindAll")
    public CommonResult backfindAll(Integer currentPage, Integer pageSize, @RequestBody Map map){
        CommonResult result = branchService.backfindAll(currentPage,pageSize,map);
        return result;
    }

    //后台---店铺详情接口
//    @PostMapping("/findGoodsByBranchid")
//    public CommonResult orderFindOrderByOrderId(Integer currentPage, Integer pageSize, @RequestBody Map map){
//        CommonResult result = branchService.orderFindOrderByOrderId(currentPage,pageSize,map);
//        System.out.println(result);
//        return result;
//    }
    //后台---店铺详情接口
    @PostMapping("/findGoodsByBranchid")
    public CommonResult orderFindOrderByOrderId(@RequestBody Map map){
        CommonResult result = branchService.orderFindOrderByOrderId(map);
        System.out.println(result);
        return result;
    }

    @PostMapping("/delbranchUser")
    public CommonResult delBranchUser(@RequestBody Branch branch){
        System.out.println(branch);
        CommonResult result = branchService.delBranchUser(branch);

        return result;
    }
}
